<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统维护</title>
    <link rel="stylesheet" href="css/first.css">
    <link rel="stylesheet" href="layui/css/layui.css">
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>

<body style="padding: 10px;">
    <span class="layui-breadcrumb bread">
        <a href="">年度综合考评</a>
        <a href="">系统维护</a>
    </span>
    <div class="section_bread">
        <span class="bread2">
            <span class="listspan" href="service.html" style="color: rgb(72, 192, 244);">台账审核</span>
            <span class="listspan" href="serviceMsg.html">系统维护信息</span>
        </span>
    </div>
    <div class="layuimini-container content">
        <div class="layuimini-main">

            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="" style="display: flex;">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">年份</label>
                                <div class="layui-input-block">
                                    <select name="interest" lay-filter="aihao">
                                        <option value=""></option>
                                        <option value="0">2021年</option>
                                        <option value="1">2020年</option>
                                        <option value="2">2019年</option>
                                        <option value="3">2018年</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">发布状态</label>
                                <div class="layui-input-block">
                                    <select name="interest" lay-filter="aihao">
                                        <option value=""></option>
                                        <option value="0">待审核</option>
                                        <option value="1">待提交</option>
                                        <option value="2">审核通过</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit=""
                                    lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>

            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm data-add-btn"> 添加用户 </button>
                <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn"> 驳回用户 </button>
            </div>

            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
            <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1" lay-id="currentTableId"
                style=" ">
                <div class="layui-table-tool">
                    <div class="layui-table-tool-self">
                        <div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS"><i
                                class="layui-icon layui-icon-cols"></i></div>
                        <div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT"><i
                                class="layui-icon layui-icon-export"></i></div>
                        <div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT"><i
                                class="layui-icon layui-icon-print"></i></div>
                        <div class="layui-inline" title="提示" lay-event="LAYTABLE_TIPS"><i
                                class="layui-icon layui-icon-tips"></i></div>
                    </div>
                </div>
 
                <div class="layui-table-page">
                    <div id="layui-table-page1">
                        <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1"><a
                                href="javascript:;" class="layui-laypage-prev layui-disabled" data-page="0"><i
                                    class="layui-icon"></i></a><span class="layui-laypage-curr"><em
                                    class="layui-laypage-em"></em><em>1</em></span><a href="javascript:;"
                                data-page="2">2</a><a href="javascript:;" data-page="3">3</a><span
                                class="layui-laypage-spr">…</span><a href="javascript:;" class="layui-laypage-last"
                                title="尾页" data-page="67">67</a><a href="javascript:;" class="layui-laypage-next"
                                data-page="2"><i class="layui-icon"></i></a><span class="layui-laypage-skip">到第<input
                                    type="text" min="1" value="1" class="layui-input">页<button type="button"
                                    class="layui-laypage-btn">确定</button></span><span class="layui-laypage-count">共 1000
                                条</span><span class="layui-laypage-limits"><select lay-ignore="">
                                    <option value="10">10 条/页</option>
                                    <option value="15" selected="">15 条/页</option>
                                    <option value="20">20 条/页</option>
                                    <option value="25">25 条/页</option>
                                    <option value="50">50 条/页</option>
                                    <option value="100">100 条/页</option>
                                </select></span></div>
                    </div>
                </div>
            </div>


        </div>
    </div>

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="./layui/layui.js"></script>
    <script>
        $(".listspan").click(function () {
            var src = $(this).attr('href');
            window.open(src, '_self');
        });
        layui.use('element', function () {
            var element = layui.element;
            //导航的hover效果、二级菜单等功能，需要依赖element模块
            //导航点击事件
            element.on('nav(demo)', function (elem) {
                layer.msg(elem.text());
            });
        });
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                layuimini = layui.layuimini;

            $.ajax({
                url: "http://172.16.109.14:8080/StandingBookReviewAmend",
                type: "get",
                data: { index: 1 },
                dataType: "json",
                success: function (res) {
                    console.log(res);
                    var json = JSON.parse(res.data).uis
                    console.log(json);

                    table.render({
                        elem: '#currentTableId',
                        toolbar: '#toolbarDemo',
                        data: json,
                        defaultToolbar: ['filter', 'exports', 'print', {
                            layEvent: 'LAYTABLE_TIPS',
                            icon: 'layui-icon-tips'
                        }],
                        cols: [[
                            { type: "checkbox", width: 50, fixed: "left" },
                            { field: 'id', width: 120, title: '编号', sort: true },
                            { field: 'onetarget', width: 110, title: '一级指标' },
                            { field: 'twotarget', width: 110, title: '二级指标' },
                            { field: 'nameoforganization', width: 110, title: '考评对象' },
                            { field: 'lndividual', width: 100, title: '单选考核分' },
                            { field: 'oneselfscore', width: 100, title: '自评分' },
                            { field: 'score', width: 100, title: '分值' },
                            { field: 'state', width: 100, title: '状态' },
                            { field: 'year', width: 100, title: '年份' },
                            { field: 'standingbookname', width: 100, title: '台账内容' },
                            { field: 'standingbookcontent', width: 100, title: '落实情况' },
                            { title: '操作', width: 180, minWidth: 150, templet: '#currentTableBar', fixed: "right", align: "center" }
                        ]],
                        // limits: [10, 15, 20, 25, 50, 100],
                        limit: 10,
                        page: true
                    });
                },
                error: function () {
                    alert("请求失败！")
                }
            });

            // 监听搜索操作
            form.on('submit(data-search-btn)', function (data) {
                var result = JSON.stringify(data.field);
                layer.alert(result, {
                    title: '最终的搜索信息'
                });

                //执行搜索重载
                table.reload('currentTableId', {
                    page: {
                        curr: 1
                    }
                    , where: {
                        searchParams: result
                    }
                }, 'data');

                return false;
            });

            // 监听添加操作
            $(".data-add-btn").on("click", function () {

                var index = layer.open({
                    title: '添加用户',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: './add15.html',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });

                return false;
            });

            // 监听驳回操作
            $(".data-delete-btn").on("click", function () {
                var checkStatus = table.checkStatus('currentTableId')
                    , data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            });

            //监听表格复选框选择
            table.on('checkbox(currentTableFilter)', function (obj) {
                console.log(obj)
            });

            table.on('tool(currentTableFilter)', function (obj) {
                var data = obj.data;
                var id = $(this).parent().parent().prev().prev().prev().prev().prev().prev().prev().prev().prev().prev().prev().children().text();
                var lndividual = $(this).parent().parent().prev().prev().prev().prev().prev().prev().prev().children().html("120").text();
                console.log(id);
                console.log(lndividual);
                if (obj.event === 'edit') {
                    layer.confirm('确认要通过吗', function (index) {
                        layer.close(index);
                        $.ajax({
                            type: 'get',
                            dataType: 'json',
                            url: 'http://172.16.109.14:8080/AuditOfLedgerAppeal',
                            data: {
                                id:id,
                                lndividual:lndividual
                            },
                            success: function (res) {
                                // console.log(res);
                                alert(res.message);
                            },
                            error: function () {
                                // console.log(res);
                                alert(res.message);
                            }
                        })
                    });
                } 
                
            });
        }); 
    </script>
    <script type="text/html" id="currentTableBar">
        <a class="layui-btn layui-btn-xs data-count-edit" lay-event="edit">审核</a>
        <!-- <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">驳回</a> -->
    </script>
</body>

</html>